// 以类作为参数
class User {
    username: string | undefined
    password: string | undefined
}

class MysqlDb2 {
    add(user: User): boolean {
        return true
    }
}

class MysqlDb3<T> {
    add(info: T): boolean {
        return true;
    }
}

// 完整泛型接口
interface DBI<T> {
    add(info: T): boolean;

    update(info: T, id: number): Boolean;

    delete(id: number): boolean;

    get(id: number): any[];
}

// 完整泛型类
class MysqlDb<T> implements DBI<T> {
    add(info: T): boolean {
        return false;
    }

    delete(id: number): boolean {
        return false;
    }

    get(id: number): any[] {
        return [];
    }

    update(info: T, id: number): Boolean {
        return false;
    }

}

// 其他写法
interface Inter {
    length: number;
}

function fn3<T extends Inter>(val: T): number {
    return 100;
}

export {}